package com.itheima.filter;

import com.github.pagehelper.BoundSqlInterceptor;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.xml.ws.WebFault;
import java.io.IOException;


//@WebFilter(urlPatterns = "/*")
//拦截所有请求，是Javaweb的请求
public class DemoFilter implements Filter {
    @Override
//    初始化方法，只被调用一次
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("init初始化方法执行了");


    }

    @Override
    //每次拦截到请求之后都执行一次，会调用多次
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("Demo拦截到请求");
        //放行操作
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    //销毁方法，只调用一次
    public void destroy() {
        System.out.println("destroy销毁方法执行了");
    }
}
